package com.ch.home.testMapper;

import com.ch.home.bean.UserComment;
import com.ch.home.mapper.userMessageMapper.UserCommentMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.LinkedList;

/**
 * Created by CHEN on 2019/8/17.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class testUserCommentMapper {

    @Autowired
    UserCommentMapper userCommentMapper;




    @Test
    public void testSelectByCondition() {
        int comment_id = 1;
        System.out.println(userCommentMapper.selectByCondition(comment_id));
    }

    //ok
    @Test
    public void testInsertUserComment() {

        Date date = new Date( );
        UserComment userComment = new UserComment(null, 3, 1, 2, date, "测试评论", null, null,0);
        System.out.println(userCommentMapper.insertUserComment(userComment));

    }


    //ok
    @Test
    public void testSelectAllByCondition() {
        UserComment userComment = new UserComment( );
        userComment.setUserId(1);
        LinkedList<UserComment> userComments = userCommentMapper.selectAllByCondition(userComment);
        for (UserComment u : userComments
                ) {
            System.out.println(u);
        }
    }

    @Test
    public void testUpdateUserCommentByCondition() {
        UserComment userComment = new UserComment();
        userComment.setCommentId(4);
        userComment.setTime(new Date());
        userComment.setLikeNum(2);
        userComment.setStatus(0);
        System.out.println( userCommentMapper.updateUserCommentByCondition(userComment));
    }





}
